package com.example.mybatis.Annotation1;

import org.springframework.web.bind.annotation.RestController;

import java.lang.annotation.Annotation;

@MyAnnotation(name = "MyUser")
public class User {
   private String name;
   private int age;
}
public class Test04 {
    public static void main(String[] args) throws ClassNotFoundException{
        Class aClass =Class.forName("com.example.mybatis.Annotation1.User");

        Annotation declaredAnnotation = aClass.getDeclaredAnnotation(MyAnnotation.class);

        if(declaredAnnotation instanceof MyAnnotation){
            MyAnnotation myAnnotation = (MyAnnotation) declaredAnnotation;

            System.out.println(myAnnotation.name());
        }

        if(declaredAnnotation instanceof RestController){
            System.out.println("declaredAnnotation is a RestController annotation");
        }else{
            System.out.println("declaredAnnotation is not a RestController annotation");
        }
    }
}
